import React, { Component } from 'react'
import './Company.css'

export default class Company extends Component {

  constructor(props) {
  super(props);
  this.state={
    select: -1
  };}

  onTab({item, index}) {
    this.setState({
      select: index
    })
    this.props.onTab({item, index})
  }

  render() {
    const {list} = this.props;
    return (
      <div className="org_company">
      {list.map((item, index) => {
          return (
            <div key={index} style={this.state.select === index ? {color: '#b0200c'} : {color: '#242424'}} 
              onClick={() => this.onTab({item, index})}>
              {item.name}
            </div>
          );
        })}
      </div>
    )
  }
}
